package com.xhj.springbootproject.controller;

import com.xhj.springbootproject.service.intf.RedisClient;
import com.xhj.springbootproject.util.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ：Xionghaijun
 * @date ：Created in 2019/8/5 5:37 PM
 * @description：
 */
@Api(value = "redis调用",tags = "redis测试")
@RestController
public class RedisController {

    private final Logger logger = LoggerFactory.getLogger(RedisController.class);

    @Autowired
    private RedisClient redisClient;

    @Autowired
    private Environment env;


    @RequestMapping(value = "/redis", method = RequestMethod.GET)
    @ApiOperation(value = "redis",notes = "redis测试接口")
    public JsonResult redis() {

        redisClient.set("test1", "hello,Redis");
        redisClient.expire("test1", 2);
        String result = redisClient.get("test1");
        System.out.println(result);
        System.out.println(env.getProperty("mybatis.mapper-locations"));
        Map map = new HashMap<>();

        return JsonResult.getSuccessResult().fillData(result);
    }

}
